package com.centaline.androidsalesblog.rx.database;

import com.centaline.androidsalesblog.constants.CommonConstant;
import com.centaline.androidsalesblog.model.businissobject.DropBo;
import com.centaline.androidsalesblog.model.databaseobject.GscpDo;
import com.centaline.androidsalesblog.model.databaseobject.RegionDo;

import java.util.ArrayList;

import rx.functions.Func1;

/**
 * 下拉菜单-租售区域
 * Created by guilin on 16/1/25.
 */
public class DropSaleRegionFunc1 implements Func1<ArrayList<RegionDo>, ArrayList<DropBo>> {

    @Override
    public ArrayList<DropBo> call(ArrayList<RegionDo> regionDos) {
        final ArrayList<DropBo> list = new ArrayList<>();
        DropBo dropBo1, dropBo2;
        for (RegionDo regionDo : regionDos) {
            dropBo1 = new DropBo(10);
            dropBo1.setText(regionDo.getC_distname());
            dropBo1.setValue(regionDo.getScp_mkt());
            ArrayList<DropBo> temp = new ArrayList<>();
            dropBo2 = new DropBo(10);
            dropBo2.setText(CommonConstant.DROP_TEXT_NO_LIMITED);
            dropBo2.setValue(CommonConstant.DROP_VALUE_NULL);
            temp.add(dropBo2);
            final ArrayList<GscpDo> gscpDos = regionDo.getList();
            for (GscpDo gscpDo : gscpDos) {
                dropBo2 = new DropBo(10);
                dropBo2.setText(gscpDo.getC_distname());
                dropBo2.setValue(gscpDo.getGscp_id());
                temp.add(dropBo2);
            }
            dropBo1.setChildrenList(temp);
            list.add(dropBo1);
        }
        return list;
    }

}
